<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                template="/mytemplate.xhtml">

    <ui:define name="metadata">
    </ui:define>
    <ui:define name="content">

        <h:form id="form">  

            <p:dataTable id="dataTable" var="e" value="#{equipmentService.equipments}" paginator="true" rows="15"  
                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
                         selection="#{equipmentService.selectedEquipment}" selectionMode="single"
                         rowKey="#{e.id}">  

                <f:facet name="header">  
                    Equipments List
                </f:facet>  

                <p:column sortBy="#{e.name}" headerText="Name">  
                    <h:outputText value="#{e.name}" />  
                </p:column>  

                <p:column sortBy="#{e.address}" headerText="Address">  
                    <h:outputText value="#{e.address}" />  
                </p:column>  

                <p:column sortBy="#{e.type}" headerText="Type">  
                    <h:outputText value="#{e.type}" />  
                </p:column>  

                <p:column sortBy="#{e.creationDate}" headerText="Creation date">  
                    <h:outputText value="#{e.creationDate}" />  
                </p:column>  

                <p:column sortBy="#{e.modificationDate}" headerText="Modification date">  
                    <h:outputText value="#{e.modificationDate}" />  
                </p:column> 

                <p:column sortBy="#{e.stringState}" headerText="State">  
                    <h:outputText value="#{e.stringState}" />  
                </p:column> 

                <f:facet name="footer">  
                    <p:commandButton id="viewButton" value="View" icon="ui-icon-search"  
                                     update=":mainForm:form:display, :mainForm:form:dataTablePorts" oncomplete="portsDialog.show()"/>  
                </f:facet>  
            </p:dataTable> 

            <p:dialog id="portsDialog" header="Equipment Detail" widgetVar="portsDialog" resizable="false"  
                       showEffect="clip" hideEffect="fold">  

                <h:panelGrid id="display" columns="2" cellpadding="4">  

                    <h:outputText value="Name: " />  
                    <h:outputText value="#{equipmentService.selectedEquipment.name}" />  
                    <h:outputText value="Type :" />
                    <h:outputText value="#{equipmentService.selectedEquipment.type}" />   
                </h:panelGrid>  
                    <p:dataTable id="dataTablePorts" var="p" value="#{equipmentService.selectedEquipment.ports}" paginator="true" rows="15"  
                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
                         rowKey="#{p.id}">  

                        <f:facet name="header">  
                            Ports List
                        </f:facet>  

                        <p:column sortBy="#{p.name}" headerText="Name">  
                            <h:outputText value="#{p.name}" />  
                        </p:column>  


                        <p:column sortBy="#{p.innerConnectedPort.name}" headerText="Inner Connection">  
                            <h:outputText value="#{p.innerConnectedPort.name}" />  
                        </p:column>  

                        <p:column sortBy="#{p.outerConnectedPort.equipment.name} #{p.outerConnectedPort.name}" headerText="Outer Connection">  
                            <h:outputText value="#{p.outerConnectedPort.equipment.name} #{p.outerConnectedPort.name}" />  
                        </p:column>

                        <p:column sortBy="#{p.modificationDate}" headerText="Modification date">  
                            <h:outputText value="#{e.modificationDate}" />  
                        </p:column> 

                        <p:column sortBy="#{p.stringState}" headerText="State">  
                            <h:outputText value="#{p.stringState}" />  
                        </p:column>  
                    </p:dataTable> 
                
                
            </p:dialog>  

        </h:form> 

    </ui:define>
</ui:composition>